package com.fjec.market.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjec.common.protocol.JsonResult;
import com.fjec.common.shiro.AccountInfo;
import com.fjec.market.entity.BizSubPhysicalOrder;
import com.fjec.market.service.IBizSubPhysicalOrderService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 042.实物子订单表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2020-09-21
 */
@RestController
@RequestMapping("")
public class BizSubPhysicalOrderController {

    @Resource
    private IBizSubPhysicalOrderService service;

    @GetMapping("/y/phy/order/get/my/dividings")
    public JsonResult getMyDividings(Page page) {
        Long busiId = AccountInfo.getBusiId();
        List<Map<String, Object>> result = service.getMyDividings(busiId, page);
        return JsonResult.success()
                .data(result)
                .total(page.getTotal())
                .build();

    }

    @GetMapping("/y/phy/order/get/my/dividings/stat")
    public JsonResult getMyDividingsStat() {
        Long busiId = AccountInfo.getBusiId();
        Map<String, Object> result = service.getMyDividingsStat(busiId);
        return JsonResult.success().data(result).build();
    }

    /**
     * paid rpc调用该接口，设置子订单分账状态为到账
     * @param paymentId
     * @return
     */
    @PostMapping("/phy/order/set/dist/accounted")
    public int setDistStatusAccounted(Long paymentId) {
        int code = service.setDistStatusAccounted(paymentId);
        return code;
    }
}
